<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.jdbc.tool.*"%>   
 <%@ page import="java.sql.*" %>
    <%
    	int pageNum = 1;//当前是第几页。
    	String spageNum = request.getParameter("pageNum");
    	//一般第一次刷新都没带pageNum来，所以是空，判断是空，就选择默认的pageNum.
    	if (spageNum != null) {
    		pageNum = Integer.parseInt(spageNum);
    	}

    	int pageCount = 3;//共有多少页。
    	int pageSize = 4;//每一页的大小。
    	int rowCount = 1;//共有多少行数据
    	Connection conn = DBLianjie.getconn();
    	Statement stm = conn.createStatement();
    	//查询rowcount。
    	ResultSet rs = stm.executeQuery("select count(*) from emai_user");
    	rs.next();
    	rowCount = rs.getInt(1);
    	//得到pagecount
    	pageCount = rowCount % pageSize == 0 ? rowCount / pageSize
    			: rowCount / pageSize + 1;

    	rs = stm
    			.executeQuery("select * from (select t.*,rownum rn from(select * from emai_user order by e_user_id) t "
    					+ "where rownum<="
    					+ pageSize
    					* pageNum
    					+ ")where rn>=" + (pageSize * (pageNum - 1) + 1));
    %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'SelectAllUser.jsp' starting page</title>

	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style>
    body{
    padding:20px; 
    overflow:hidden;
    background-color: #d1e3ed;
    }
    .ti{
    background-image: url(lantian.jpg);
    width:1024px;
    height:668px;
    }
    .list{
      width:100%;
      border-top:2px solid #dfc9b2;
      border-bottom:2px solid #dfc9b2;
    }
    .list th{
    width:90px;
    background:#f7f4eb;
    color:#8a7152;
    }
    .fenye{
    margin-left:250;
    }
    .fenye a{
    margin-left:20px;
    text-decoration: none;
    color: #8a7152;
    }
    #sub{
    width:55px;
    height:50px;
    border:none;
    background:transparent url("shanchu.png") no-repeat;
    }
.pager { margin-top:15px; }
.pager ul { float:right; }
.pager ul li { float:left; border:2px solid #109ef2; line-height:18px; padding:0 3px; margin:0 1px; display:inline; }
.pager ul li.current { font-weight:bold; color:#630; }
.pager ul li a{text-decoration:none}
</style>

  </head>
  
  <body>
     <div class="ti">
     <div class="list">
      <table>
      <tr>
      <div>
      <th>用户ID</th>
      <th>用户姓名</th>
      <th>用户密码</th>
      <th>性别</th>
      <th>出生日期</th>
      <th>身份证ID</th>
      <th>邮箱</th>
      <th>电话</th>
      <th>地址</th>
      <th>级别</th>
      <th>备注</th>
      <th>&nbsp;</th>
      </div>
      </tr>
 <%
 	while (rs.next()) {
 %>
      <tr>
      <td><%=rs.getString("e_user_id")%></td>
      <td><%=rs.getString("e_user_name")%></td>
      <td><%=rs.getString("E_PASSWORD")%></td>
      <td><%=rs.getString("e_sex")%></td>
      <td><%=rs.getDate("E_BRITHDAY")%></td>
      <td><%=rs.getString("E_IDENTITY_CODE")%></td>
      <td><%=rs.getString("e_emial")%></td>
      <td><%=rs.getString("e_mobile")%></td>
      <td><%=rs.getString("E_ADDRESS")%></td>
      <td><%=rs.getString("E_STATUS")%></td>
      <td><%=rs.getString("E_LJ")%></td>
      <td><a href="./Usermanager?userid=<%=rs.getString("e_user_id")%>" id="sub"><div style="width:52px;height:25px;background-image:url('shanchu.png');"></div></a></td>
      </tr>
      <%
      	}
      %>
      </table>
       <div class="pager">
     <ul class="clearfix">
     <%if(pageNum-1>1){%>
      <li><a href="Delete.jsp?pageNum=<%=pageNum-1%>"><%="上一页"%></a></li>
      <%}else{%>
	<li><a href="Delete.jsp?pageNum=<%=1%>"><%="上一页"%></a></li>
	   <% }%>
					
      <%
      	for (int i = 1; i <= pageCount; i++) {
      		if(i==pageNum){
      %>
             <li class="current"><%=i%></li>
           <%}else{%>
             <li><a href="Delete.jsp?pageNum=<%=i%>"><%=i%></a></li>
      <%
      	}}
      %>
       <%if(pageNum+1<=pageCount){%>
      <a href="Delete.jsp?pageNum=<%=pageNum+1%>"><%="下一页"%></a>
      <%}else{%>
					<li><a href="Delete.jsp?pageNum=<%=pageCount%>"><%="下一页"%></a></li>
					<%}%>
      </div>
      </div>
  </body>
</html>

